<template>
  <!-- 头部栏 -->
  <div class="header">
    <h1>文章管理系统</h1>
    <div class="hamburger" @click="toggleSidebar">☰</div>
  </div>

  <!-- 主体容器 -->
  <div class="main-container">
    <!-- 左侧导航栏 -->
    <div class="sidebar" :class="{ 'sidebar-collapsed': isCollapsed }">
      <button class="nav-btn" @click="linkRoute1">
        <Document class="btn-icon" />
        <span>文章列表</span>
      </button>
      <button class="nav-btn" @click="linkRoute2">
        <Edit class="btn-icon" />
        <span>新建文章</span>
      </button>
    </div>

    <!-- 右侧内容区 -->
    <div class="content">
      <RouterView />
    </div>
  </div>
</template>


<script setup lang="ts">
 import { ref } from 'vue'
 import { RouterView,createRouter,RouterLink} from 'vue-router';
 import { Delete, Edit, Document} from '@element-plus/icons-vue'
import { useRouter } from 'vue-router';
  let router =useRouter()
  let linkRoute1=()=>{
      router.push( '/articleList')
  }
  let linkRoute2=()=>{
      router.push('/addarticle')
  }

    
</script>


<style scoped>
.header {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  padding: 16px 24px;
  background: #1b2535; /* 深蓝灰背景 */
  box-shadow: 0 4px 8px rgba(0,0,0,0.15);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.header h1 {
  color: #f0f4f8;
  font-size: 1.5rem;
  font-weight: 600;
  letter-spacing: 0.5px;
  margin: 0;
}

.hamburger {
  color: #fff;
  font-size: 1.8rem;
  cursor: pointer;
  display: none;
}
.sidebar {
  position: fixed;
  top: 60px;
  left: 0;
  bottom: 0;
  width: 240px;
  background: #2c3e50; /* 深色背景 */
  padding: 20px 0;
  transition: transform 0.3s ease;
  z-index: 999;
}

.nav-btn {
  width: calc(100% - 24px);
  margin: 8px 12px;
  padding: 12px 20px;
  background: #34495e;
  border: none;
  border-radius: 8px;
  color: #ecf0f1;
  display: flex;
  align-items: center;
  gap: 12px;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.nav-btn:hover {
  background: #3b556d;
  transform: translateX(8px);
  box-shadow: 2px 4px 12px rgba(52, 152, 219, 0.2);
}

.btn-icon {
  width: 1.2rem;
  height: 1.2rem;
  color: #3498db;
}
.content {
  margin-left: 240px;
  margin-top: 60px;
  padding: 32px;
  min-height: calc(100vh - 60px);
  background: #f8f9fa;
}

/* 卡片容器示例 */
.content-card {
  background: white;
  border-radius: 12px;
  padding: 24px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
  margin-bottom: 24px;
}
@media (max-width: 768px) {
  .hamburger {
    display: block;
  }

  .sidebar {
    transform: translateX(-100%);
    top: 60px;
  }

  .sidebar.sidebar-collapsed {
    transform: translateX(0);
  }

  .content {
    margin-left: 0;
    width: 100%;
    padding: 24px 16px;
  }

  .nav-btn span {
    display: none;
  }

  .btn-icon {
    margin-right: 0;
  }
}


</style>